package controllers


import (
	"github.com/astaxie/beego"
	"fmt"
	m"xmy/models/admin"

)

type BusinessController struct {
	beego.Controller
}

//返回值 封装为 JSON 格式
func (this *BusinessController) Rsp(status bool, str string) {
	this.Data["json"] = &map[string]interface{}{"status": status, "info": str}
	this.ServeJSON()
}

//入台证管理
func (c *BusinessController)  EntryCardManage() {
	fmt.Println("进来--入台证管理--控制器啦！")
	c.TplName = "business/entryCardManage.html"
}

//入台证申请列表
func (this *BusinessController)  EntryCardManagePage() {
	fmt.Println("进来--申请列表--控制器啦！")
	applys := m.GetApplyList()
	this.Data["json"] = &map[string]interface{}{"rows": &applys}
	fmt.Println(this.Data["json"])
	this.ServeJSON()
	return
}


//入台证费用管理
func (c *BusinessController)  EntryCardCost() {
	fmt.Println("进来--入台证费用管理--控制器啦！")
	c.TplName = "business/entryCardCost.html"
}

//入台证费用列表
func (this *BusinessController)  EntryCardCostPage() {
	fmt.Println("进来--费用列表--控制器啦！")
	costs := m.GetCostList()
	this.Data["json"] = &map[string]interface{}{"rows": &costs}
	fmt.Println(this.Data["json"])
	this.ServeJSON()
	return
}

//入台证 协议 管理
func (c *BusinessController)  EntryCardAgreement() {
	fmt.Println("进来--入台证 协议 管理--控制器啦！")
	c.TplName = "business/entryCardAgreement.html"
}


//入台证 协议 详情
func (c *BusinessController)  AgreementDetail() {
	fmt.Println("进来--入台证 协议 详情--控制器啦！")
	agreements:= m.QueryAgreement()
	c.Data["json"] = &map[string]interface{}{"rows": &agreements}
	c.ServeJSON()
	return
}

//入台证 协议 编辑
func (c *BusinessController)  AgreementEdit() {
	fmt.Println("进来--入台证 协议 编辑--控制器啦！")
	agreementcontent := c.GetString("agreementcontent")
	id:= m.AgreementEdit(agreementcontent)
	if  id > 0 {
		c.Rsp(true, "Success")
		return
	} else {
		c.Rsp(false, "error")
		return
	}
}